home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / COMPTOOL / ACTVCOMP / ACTXDOC / FRMABOUT.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-09-16  |  9.0 KB  |  208 lines

  1. VERSION 5.00
  2. Begin VB.Form frmAbout 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "About FirstDoc"
  5.    ClientHeight    =   3555
  6.    ClientLeft      =   1320
  7.    ClientTop       =   2100
  8.    ClientWidth     =   5730
  9.    ClipControls    =   0   'False
  10.    LinkTopic       =   "Form2"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   2453.724
  14.    ScaleMode       =   0  'User
  15.    ScaleWidth      =   5380.766
  16.    ShowInTaskbar   =   0   'False
  17.    StartUpPosition =   2  'CenterScreen
  18.    Begin VB.PictureBox picIcon 
  19.       AutoSize        =   -1  'True
  20.       BackColor       =   &H00C0C0C0&
  21.       ClipControls    =   0   'False
  22.       Height          =   540
  23.       Left            =   240
  24.       Picture         =   "frmAbout.frx":0000
  25.       ScaleHeight     =   337.12
  26.       ScaleMode       =   0  'User
  27.       ScaleWidth      =   337.12
  28.       TabIndex        =   1
  29.       Top             =   240
  30.       Width           =   540
  31.    End
  32.    Begin VB.CommandButton cmdOK 
  33.       Cancel          =   -1  'True
  34.       Caption         =   "OK"
  35.       Default         =   -1  'True
  36.       Height          =   345
  37.       Left            =   4245
  38.       TabIndex        =   0
  39.       Top             =   2625
  40.       Width           =   1260
  41.    End
  42.    Begin VB.CommandButton cmdSysInfo 
  43.       Caption         =   "&System Info..."
  44.       Height          =   345
  45.       Left            =   4260
  46.       TabIndex        =   2
  47.       Top             =   3075
  48.       Width           =   1245
  49.    End
  50.    Begin VB.Line Line1 
  51.       BorderColor     =   &H00808080&
  52.       BorderStyle     =   6  'Inside Solid
  53.       Index           =   1
  54.       X1              =   84.515
  55.       X2              =   5309.398
  56.       Y1              =   1687.583
  57.       Y2              =   1687.583
  58.    End
  59.    Begin VB.Label lblDescription 
  60.       Caption         =   "ActiveX Document"
  61.       ForeColor       =   &H00000000&
  62.       Height          =   1170
  63.       Left            =   1050
  64.       TabIndex        =   3
  65.       Top             =   1125
  66.       Width           =   3885
  67.    End
  68.    Begin VB.Label lblTitle 
  69.       Caption         =   "FirstDoc ActiveX Document"
  70.       ForeColor       =   &H00000000&
  71.       Height          =   480
  72.       Left            =   1050
  73.       TabIndex        =   4
  74.       Top             =   240
  75.       Width           =   3885
  76.    End
  77.    Begin VB.Line Line1 
  78.       BorderColor     =   &H00FFFFFF&
  79.       BorderWidth     =   2
  80.       Index           =   0
  81.       X1              =   98.6
  82.       X2              =   5309.398
  83.       Y1              =   1697.936
  84.       Y2              =   1697.936
  85.    End
  86.    Begin VB.Label lblVersion 
  87.       Caption         =   "Version 1.0"
  88.       Height          =   225
  89.       Left            =   1050
  90.       TabIndex        =   5
  91.       Top             =   780
  92.       Width           =   3885
  93.    End
  94. Attribute VB_Name = "frmAbout"
  95. Attribute VB_GlobalNameSpace = False
  96. Attribute VB_Creatable = False
  97. Attribute VB_TemplateDerived = False
  98. Attribute VB_PredeclaredId = True
  99. Attribute VB_Exposed = False
  100. Option Explicit
  101. ' Reg Key Security Options...
  102. Const READ_CONTROL = &H20000
  103. Const KEY_QUERY_VALUE = &H1
  104. Const KEY_SET_VALUE = &H2
  105. Const KEY_CREATE_SUB_KEY = &H4
  106. Const KEY_ENUMERATE_SUB_KEYS = &H8
  107. Const KEY_NOTIFY = &H10
  108. Const KEY_CREATE_LINK = &H20
  109. Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
  110.                        KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
  111.                        KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
  112.                      
  113. ' Reg Key ROOT Types...
  114. Const HKEY_LOCAL_MACHINE = &H80000002
  115. Const ERROR_SUCCESS = 0
  116. Const REG_SZ = 1                         ' Unicode nul terminated string
  117. Const REG_DWORD = 4                      ' 32-bit number
  118. Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Shared Tools Location"
  119. Const gREGVALSYSINFOLOC = "MSINFO"
  120. Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Shared Tools\MSINFO"
  121. Const gREGVALSYSINFO = "PATH"
  122. Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
  123. Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
  124. Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
  125. Private Sub cmdSysInfo_Click()
  126.   Call StartSysInfo
  127. End Sub
  128. Private Sub cmdOK_Click()
  129.   Unload Me
  130. End Sub
  131. Private Sub Form_Load()
  132.   Me.Caption = "About " & App.Title
  133.   lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision
  134.   lblTitle.Caption = App.Title
  135. End Sub
  136. Public Sub StartSysInfo()
  137.   On Error GoTo SysInfoErr
  138.   Dim rc As Long
  139.   Dim SysInfoPath As String
  140.   ' Try To Get System Info Program Path\Name From Registry...
  141.   If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, SysInfoPath) Then
  142.   ' Try To Get System Info Program Path Only From Registry...
  143.   ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, SysInfoPath) Then
  144.       ' Validate Existance Of Known 32 Bit File Version
  145.       If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then
  146.           SysInfoPath = SysInfoPath & "\MSINFO32.EXE"
  147.           
  148.       ' Error - File Can Not Be Found...
  149.       Else
  150.           GoTo SysInfoErr
  151.       End If
  152.   ' Error - Registry Entry Can Not Be Found...
  153.   Else
  154.       GoTo SysInfoErr
  155.   End If
  156.   Call Shell(SysInfoPath, vbNormalFocus)
  157.   Exit Sub
  158. SysInfoErr:
  159.   MsgBox "System Information Is Unavailable At This Time", vbOKOnly
  160. End Sub
  161. Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean
  162.   Dim i As Long                                           ' Loop Counter
  163.   Dim rc As Long                                          ' Return Code
  164.   Dim hKey As Long                                        ' Handle To An Open Registry Key
  165.   Dim hDepth As Long                                      '
  166.   Dim KeyValType As Long                                  ' Data Type Of A Registry Key
  167.   Dim tmpVal As String                                    ' Tempory Storage For A Registry Key Value
  168.   Dim KeyValSize As Long                                  ' Size Of Registry Key Variable
  169.   '------------------------------------------------------------
  170.   ' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
  171.   '------------------------------------------------------------
  172.   rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key
  173.   If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' Handle Error...
  174.   tmpVal = String$(1024, 0)                             ' Allocate Variable Space
  175.   KeyValSize = 1024                                       ' Mark Variable Size
  176.   '------------------------------------------------------------
  177.   ' Retrieve Registry Key Value...
  178.   '------------------------------------------------------------
  179.   rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
  180.                        KeyValType, tmpVal, KeyValSize)    ' Get/Create Key Value
  181.                       
  182.   If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' Handle Errors
  183.   If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then           ' Win95 Adds Null Terminated String...
  184.       tmpVal = Left(tmpVal, KeyValSize - 1)               ' Null Found, Extract From String
  185.   Else                                                    ' WinNT Does NOT Null Terminate String...
  186.       tmpVal = Left(tmpVal, KeyValSize)                   ' Null Not Found, Extract String Only
  187.   End If
  188.   '------------------------------------------------------------
  189.   ' Determine Key Value Type For Conversion...
  190.   '------------------------------------------------------------
  191.   Select Case KeyValType                                  ' Search Data Types...
  192.   Case REG_SZ                                             ' String Registry Key Data Type
  193.       KeyVal = tmpVal                                     ' Copy String Value
  194.   Case REG_DWORD                                          ' Double Word Registry Key Data Type
  195.       For i = Len(tmpVal) To 1 Step -1                    ' Convert Each Bit
  196.           KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1)))   ' Build Value Char. By Char.
  197.       Next
  198.       KeyVal = Format$("&h" + KeyVal)                     ' Convert Double Word To String
  199.   End Select
  200.   GetKeyValue = True                                      ' Return Success
  201.   rc = RegCloseKey(hKey)                                  ' Close Registry Key
  202.   Exit Function                                           ' Exit
  203. GetKeyError:    ' Cleanup After An Error Has Occured...
  204.   KeyVal = ""                                             ' Set Return Val To Empty String
  205.   GetKeyValue = False                                     ' Return Failure
  206.   rc = RegCloseKey(hKey)                                  ' Close Registry Key
  207. End Function
  208.